package com.site.web;

import com.night.common.entity.ResultVo;
import com.night.common.entity.logistical.Dormitory;
import com.site.service.DormitoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName: DormitoryController
 * @author: LJC
 * @date: 2022/10/24-10:43
 * 宿舍
 */
@RestController
@RequestMapping("/api/lot/dmy")
public class DormitoryController {
    @Autowired
    private DormitoryService dormitoryService;

    //添加宿舍信息
    @RequestMapping("/add")
    public ResultVo<?> add(Dormitory dormitory){
        dormitoryService.addDormitory(dormitory);
        return ResultVo.SUCCESS;
    }

    //修改宿舍信息
    @RequestMapping("/update")
    public ResultVo<?> updateDormitory(Dormitory dormitory){
        dormitoryService.updateDormitory(dormitory);
        return ResultVo.SUCCESS;
    }

    //查询所有信息
    @RequestMapping("/getAll")
    public ResultVo<?> getAll(){
        List<Dormitory> list = dormitoryService.getAll();
        return new ResultVo(200,"OK",list);
    }
}
